cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
cmake_policy(SET CMP0054 NEW)

set(PROJECT_VERSION 0.2.0)
project(SV2CameraCppNodes VERSION ${PROJECT_VERSION} LANGUAGES CXX)

add_definitions(-DAPI_EXPORTS)
set(CMAKE_BUILD_TYPE "Release")

message(STATUS "System:${CMAKE_HOST_SYSTEM_PROCESSOR}")

add_definitions(-DWITH_GSTREAMER)
find_package(SpireMS REQUIRED)
find_package(OpenCV 4 REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")


include_directories(${SpireMS_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)


include_directories(
   "/usr/include/gstreamer-1.0"
   "/usr/local/include/gstreamer-1.0"
   "/usr/include/glib-2.0"
   "/usr/lib/aarch64-linux-gnu/glib-2.0/include"
)



# Public header
set(HEADS
  include/RTSP_Gstreamer.hpp
  include/sv2_streamer.h
)

set(SRCS
  src/RTSP_Gstreamer.cpp
  src/sv2_streamer.cpp
)

add_library(sv2_world SHARED ${SRCS})
target_link_libraries(
    sv2_world ${OpenCV_LIBS} 
    ${SpireMS_LIBS}
)

target_link_libraries(sv2_world gstrtspserver-1.0)

# Demo
add_executable(SV2StreamerDemo SV2StreamerDemo.cpp)
target_link_libraries(SV2StreamerDemo sv2_world)


install(TARGETS SV2StreamerDemo
  RUNTIME DESTINATION bin
)
